-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[output] PagerDuty incident requires "From:" header #493
Conversation
@@ -291,21 +296,23 @@ def _check_exists_get_id(self, filter_str, url, target_key): | |||
return False | |||
|
|||
# If there are results, get the first occurence from the list | |||
return response[target_key][0]['id'] if target_key in response else False | |||
if get_id: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do the inverse please
if not get_id:
return True
# If there are results, get the first occurance from the list
return response[target_key][0]['id'] if target_key in response else False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @javuto good job catching this. some initial comments for ya
""" | ||
item_id = self._check_exists_get_id(item_str, item_url, item_key) | ||
item_url = self._get_endpoint(self._base_url, item_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good change, putting this in one place!
'type': item_type | ||
} | ||
if get_id: | ||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this dict on one line:
return {id': item_id, 'type': item_type}
return self._log_status(False) | ||
|
||
# Add From to the headers after verifying | ||
self._headers['From'] = user_email |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this header value really title case (From
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird 🤣
|
||
def _user_verify(self, user): | ||
def _user_verify(self, user, get_id=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the only time this function is called, the default value for get_id
is overridden with False
... am I missing something? When would get_id
ever be True
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In _incident_assignment
it gets called and the default True
value is used
873d748
to
1001bab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚢 🐑
0043af9
to
6406c94
Compare
Changes Unknown when pulling 6406c94 on javier-streamalert-pagerduty-incidents-bugs into ** on master**. |
to: @ryandeivert @jacknagz
cc: @airbnb/streamalert-maintainers
size: small
Background
New output to use PagerDuty Incidents was added here. The REST API requires the header
From: validpagerdutyuser@email.com
to create a new incident.Changes
From:
is added to authentication, and the user will be added when creating new output._check_exists
to optionally return just a boolean.Testing